/*
* $Id: DeleteForm.java 266 2011-02-07 23:55:50Z volok-aleksej@yandex.ru $
*
* Copyright 2008-2011 by Volokitin Alexey
* All rights reserved
*
*/
package apiary.ui.journal;

import apiary.Apiary;
import apiary.component.journal.Wizard;
import apiary.ui.BackScreen;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

public class DeleteForm extends BackScreen implements WizardScreen,
                                                      CommandListener
{
    Integer idForm;
    Wizard wizard;

    public DeleteForm(String name, Integer id, Wizard wiz) {
        super(name);
        idForm = id;
        wizard = wiz;
        Apiary apiary = Apiary.getInstance();
        addCommand(new Command(apiary.getLocaleString("Yes"), Command.OK, 1));
        addCommand(new Command(apiary.getLocaleString("No"), Command.CANCEL, 2));
        setCommandListener(this);
    }

    public Object GetDataForm() {
        return Boolean.TRUE;
    }

    public void setName(String value) {
        deleteAll();
        append(Apiary.getInstance().getLocaleString("IsDelete") + value);
    }

    public Integer getIdForm() {
        return idForm;
    }

    public void commandAction(Command c, Displayable d) {
        if(c.getPriority() == 1)
            wizard.save();
        Apiary.getInstance().Display(wizard.getCancelForm());
    }
}
